home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / INTDOSX.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  1.0 KB  |  44 lines

  1. /* INTDOSX.C --- p. 633 */
  2. #ifdef EXAMPLE_1
  3. #include <stdio.h>
  4. #include <dos.h>
  5. #define DOS_MAKEDIR 0x39
  6. union REGS xr;
  7. struct SREGS sr;
  8. main()
  9. {
  10.     char pathname[80];
  11.     printf("Enter name of subdirectory: ");
  12.     gets(pathname);
  13.     xr.h.ah = DOS_MAKEDIR;
  14.     sr.ds = FP_SEG(pathname);
  15.     xr.x.dx = FP_OFF(pathname);
  16.     intdosx(&xr, &xr, &sr);
  17.     if (xr.x.cflag == 1)
  18.         printf("\nError creating subdirectory\n");
  19. }
  20. #endif
  21. #include <stdio.h>
  22. #include <dos.h>
  23. #define DOS_BUFIN 0x0a
  24. static char buffer[82] = {80, 0};
  25. main()
  26. {
  27.     union REGS xr;
  28.     struct SREGS sr;
  29.     int numchars;
  30.     char far *pbuf;
  31.     pbuf = (char far *)(&buffer[0]);
  32.     printf("Enter a line: ");
  33.     sr.ds = FP_SEG(pbuf);
  34.     xr.h.ah = DOS_BUFIN;
  35.     xr.x.dx = FP_OFF(pbuf);
  36.     intdosx(&xr, &xr, &sr);
  37.         /* The number of characters not counting the carriage
  38.         * return */
  39.     numchars = buffer[1];
  40.         /* Make it an ASCIIZ string by adding a 0 at the end*/
  41.     buffer[numchars+2] = '\0';
  42.     printf("\nYou typed %d characters\n", numchars);
  43.     printf("The string is: %s", buffer+2);
  44. }